import os
import sqlite3

def print_table(conn, table):
    try:
        cursor = conn.cursor()
        cursor.execute(f"SELECT * FROM {table}")
        rows = cursor.fetchall()
        print(f"\nTable: {table}")
        if rows:
            for row in rows:
                print(row)
        else:
            print("(empty)")
    except Exception as e:
        print(f"Error reading {table}: {e}")

def check_db(db_path):
    if not os.path.exists(db_path):
        print(f"Database not found: {db_path}")
        return
    print(f"\n--- Checking {db_path} ---")
    try:
        conn = sqlite3.connect(db_path)
        print_table(conn, "users")
        print_table(conn, "notes")
        conn.close()
    except Exception as e:
        print(f"Error opening {db_path}: {e}")

if __name__ == "__main__":
    check_db("./data/magic_notes.db")
    check_db("./magic_notes.db") 